//
//  SAPVideoTableViewCell.m
//  CarsHome
//
//  Created by dapeng on 15/12/2.
//  Copyright © 2015年 dapeng. All rights reserved.
//

#import "SAPVideoTableViewCell.h"
#import "Theme-PrefixHeader.pch"
@implementation SAPVideoTableViewCell
- (void)dealloc {
    [_title release];
    [_time release];
    [_smallimg release];
    [_playcount release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.smallimg = [[UIImageView alloc] init];
        self.title = [[UILabel alloc] init];
        self.time = [[UILabel alloc] init];
        self.playcount = [[UILabel alloc] init];
        [self addSubview:self.smallimg];
        [self addSubview:self.title];
        [self addSubview:self.time];
        [self addSubview:self.playcount];
        [_smallimg release];
        [_title release];
        [_time release];
        [_playcount release];
    }return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    self.smallimg.frame = CGRectMake(10, 10, 100, 80);
    self.title.frame = CGRectMake(120, 10, self.frame.size.width - 150, 40);
    self.time.frame = CGRectMake(120, 70, 100, 20);
    self.playcount.frame = CGRectMake(self.frame.size.width - 80, 70, 80, 20);
}

- (void)setVideoTwoModel:(SAPVideoTwoModel *)videoTwoModel {
    if (_videoTwoModel != videoTwoModel) {
        [_videoTwoModel release];
        _videoTwoModel = [videoTwoModel retain];
    }
    [self.smallimg sd_setImageWithURL:[NSURL URLWithString:videoTwoModel.smallimg] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    self.title.text = videoTwoModel.title;
    self.time.text = videoTwoModel.time;
    self.playcount.text = [NSString stringWithFormat:@"%@播放", videoTwoModel.playcount];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString *passWord = [user objectForKey:@"nightModel"];
    
    if (!(passWord == nil) && [passWord isEqualToString:@"day"]) {
        self.backgroundColor = [UIColor colorWithWhite:0.126 alpha:1.000];
        self.title.textColor = RGB(153.0,153.0,153.0,1.0f);;
        self.time.textColor = RGB(153.0,153.0,153.0,1.0f);
        self.playcount.textColor = RGB(153.0,153.0,153.0,1.0f);
        
    }else{
        self.backgroundColor = [UIColor whiteColor];
        
    }
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
